﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace RL
{
    /// <summary>
    /// Логика взаимодействия для wPrint.xaml
    /// </summary>
    public partial class wPrint : Window
    {
        public wPrint()
        {
            InitializeComponent();
        }

        private void buttonPrint_Click(object sender, RoutedEventArgs e)
        {
            routelistEntities db = new routelistEntities();
            RouteListLogic RLL = new RouteListLogic();
            RLL.ContextDB = db;
            ListReportRL rp_data = new ListReportRL();
            DateTime datestr;
            DateTime datestrend;
            try
            {
                datestr = calendar1.SelectedDate.Value;
                datestrend = datestr.AddDays(1);
            }
            catch (Exception)
            {
                datestr = DateTime.Today;
                datestrend = datestr.AddDays(1);
            }
            IEnumerable<RouteList> rl = from o in db.RouteList orderby o.nomdog where o.dt_datedoc>=datestr && o.dt_datedoc < datestrend select o;
            foreach (RouteList item in rl)
            {
                RLL.RouteList = item;
                rp_data.Add(RLL.GetRLTable());
            }
            Form1 wnd = new Form1();
            wnd.ReportData = rp_data;
            wnd.Show();
            
        }
    }
}
